/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameAcesso.java
 *
 * Created on 21/04/2012, 23:32:29
 */

package br.edu.fatec.ads.view;

import br.edu.fatec.ads.util.FrameUtil;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;

/**
 *
 * @author Ubirajara
 */
public class FrameAcesso extends javax.swing.JInternalFrame {

    /** Creates new form FrameAcesso */
    public FrameAcesso() {
        initComponents();

        FrameUtil.getInstance().removerBarraTitulo(this);

        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnAdicionaAcesso = new javax.swing.JButton();
        btnAcesso = new javax.swing.JButton();

        btnAdicionaAcesso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/fatec/ads/image/access_icon.png"))); // NOI18N
        btnAdicionaAcesso.setText("Cadastro de Acesso");
        btnAdicionaAcesso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdicionaAcessoActionPerformed(evt);
            }
        });

        btnAcesso.setIcon(new javax.swing.ImageIcon("C:\\Users\\Ubirajara\\Pictures\\door_icon.png")); // NOI18N
        btnAcesso.setText("Acessar Salas");
        btnAcesso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAcessoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(110, Short.MAX_VALUE)
                .addComponent(btnAcesso, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnAdicionaAcesso)
                .addGap(200, 200, 200))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(120, 120, 120)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAcesso)
                    .addComponent(btnAdicionaAcesso))
                .addContainerGap(117, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAdicionaAcessoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdicionaAcessoActionPerformed
        this.adicionarInternalFrame(new FrameAdicionarPermissao(), "Cadastro de Permissão de Acesso");
    }//GEN-LAST:event_btnAdicionaAcessoActionPerformed

    private void btnAcessoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAcessoActionPerformed
        this.adicionarInternalFrame(new FrameAcessarSala(), "Acesso a Salas");
    }//GEN-LAST:event_btnAcessoActionPerformed

    private void adicionarInternalFrame(JInternalFrame frame, String name){
        frame.setSize(this.getDesktopPane().getSize());
        frame.setResizable(!rootPaneCheckingEnabled);

        this.getDesktopPane().add(frame);
        this.getDesktopPane().moveToFront(frame);

        JFrame parent = (JFrame) this.getDesktopPane().getTopLevelAncestor();
        parent.setTitle(parent.getTitle() + " - " + name);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAcesso;
    private javax.swing.JButton btnAdicionaAcesso;
    // End of variables declaration//GEN-END:variables

}
